package org.opens.mybatisplus.pojo.pub2enum;

public enum State {

    NORMAL(0,"正常状态"),
    FROZEN(1,"冻结"),
    BAN(2,"禁用"),
    MUTE(3,"禁言"),
    SENSITIVE(4,"敏感用户");

    private int stateCode;
    private String stateString;


    public static State getUserStateByCode(int stateCode){
        for (State stateEnum: values()){
            if(stateEnum.getStateCode() == stateCode){
                return stateEnum;
            }
        }
        return null;
    }

    public static State getUserStateByValue(String value){
        for (State stateEnum: values()){
            if(stateEnum.name().equals(value)){
                return stateEnum;
            }
        }
        return null;
    }

    /* Constructor */
    State(int stateCode, String stateString) {
        this.stateCode = stateCode;
        this.stateString = stateString;
    }


    /* Getter and Setter */
    public int getStateCode() {
        return stateCode;
    }

    public void setStateCode(int stateCode) {
        this.stateCode = stateCode;
    }

    public String getStateString() {
        return stateString;
    }

    public void setStateString(String stateString) {
        this.stateString = stateString;
    }

}
